<%@ page session="false" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<tr:panelGroupLayout>
	<table>
		<tr>
			<td colspan="4" align="right">
			<tr:panelGroupLayout layout="horizontal" rendered="#{not SessionDataTO.readOnly}">
				<t:inputFileUpload id="fileupload" styleClass="input"
									valueChangeListener="#{orderController.uploadFileListener}" />
				<tr:message for="fileupload" styleClass="validation_info" />
				<tr:commandButton text="Wczytaj" />
			</tr:panelGroupLayout>
			</td>
		</tr>

		<tr:iterator value="#{orderBean.attachmentList}"
					binding="#{orderController.attachmentIterator}" 
					id="list" var="file">
			<tr>
				<td>
				<tr:outputText value="#{file.creationDate}" inlineStyle="font-style:italic">
					<f:convertDateTime pattern="dd-MMMMM-yyyy HH:mm" locale="pl" />
				</tr:outputText>
				</td>
				<td>
				<tr:commandLink text="#{file.name}" shortDesc="Pobierz plik"
									actionListener="#{orderController.selectAttachment}" />
				</td>
				<td>
				<tr:outputText value=" (#{file.capacity}B) " inlineStyle="font-style:italic" />
				</td>
				<td>
				<tr:commandLink actionListener="#{orderController.removeAttachment}"
								rendered="#{not SessionDataTO.readOnly}"
								onclick="return confirmMessageBox('Czy chcesz usunąć załącznik #{file.name} ?');"
								shortDesc="Usuń plik">
						<tr:image source="gfx/delete.png" />
				</tr:commandLink>
				</td>
			</tr>
		</tr:iterator>
	</table>
</tr:panelGroupLayout>